﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TEAA
{
    public class Translator
    {

        public static string TranslateSql(IDictionary<CommandType, List<string>> sql, List<RelationalOperation> operations)
        {
            System.Diagnostics.Trace.WriteLine("translate");
            //Dictionary<string, RelationalOperation> operations = new Dictionary<string, RelationalOperation>();

            SystemManager sm = SystemManager.GetSystemManager();
            List<string> selectParameters = sql[CommandType.select];
            List<string> fromParameters = sql[CommandType.from];
            //List<string> whereParameters = sql[CommandType.where];

            string tabla = null;
            IDictionary<string, string> projection = new Dictionary<string, string>();

            System.Diagnostics.Trace.WriteLine(selectParameters.Count);
            foreach (string parameter in selectParameters)
            {

                string[] splitted = parameter.Split('.');
                if (splitted.Length == 1)
                {

                }
                else
                {
                    System.Diagnostics.Trace.WriteLine(splitted[0]);
                    System.Diagnostics.Trace.WriteLine(splitted[1]);
                    projection.Add(splitted[1], splitted[0]);
                    tabla = splitted[0];
                }
            }
            Projection p = new Projection(projection);
            operations.Add(p);
            return tabla;

        }

    }
}
